/**43344343
 * 单个删除
 * @param {type} id
 * @param {type} url
 * @returns {Boolean}
 */
function itemdel(id, url) {
    if (confirm("是否确定删除所选项？")) {
        location.href = url + "&key=del&id=" + id;
    }
    return false;
}

/**
 * 批量删除
 * @param {type} name 选择的checkbox表单name
 * @param {type} url
 * @returns {Boolean}
 */
function itemdels(name, url) {
    if (confirm("是否确定删除所选项？")) {
        var chk_value = [];
        $("input[name='" + name + "[]']:checked").each(function() {
            chk_value.push($(this).attr("value"));
        });
        if (chk_value.length > 0) {
            location.href = url + "&key=dels&ids=" + chk_value;
        }
    }
    return false;
}

/**
 * 增加一行
 * @param {type} obj
 * @returns {undefined}
 */
function gitemscreen_add(obj) {
    var str = "<tr><td>";
    str += "<input type=\"file\"  name=\"fm_gitemscreen[]\">";
    str += "<button type=\"button\" class=\"btn btn-link\" onclick=\"gitemscreen_del(this);\">删除</button>";
    str += "</td></tr>";
    $("#" + obj).append(str);
}

/**
 * 删除一行
 * @param {type} obj
 * @returns {undefined}
 */
function gitemscreen_del(obj) {
    $(obj).parents("tr").detach();
}

/**
 * 复选框全选/反选
 * @param {type} name
 * @returns {undefined}
 */
function selectCheckBox(name) {
    $("#" + name).bind("click", function() {
        $("input[name='" + name + "[]']").prop("checked", this.checked);
    });
    $("input[name='" + name + "[]']").bind("click", function() {
        var $subs = $("input[name='" + name + "[]']");
        $("#" + name).prop("checked", $subs.length === $subs.filter(":checked").length ? true : false);
    });
}

/**
 * 获取URL参数
 * @param {type} name
 * @returns {unresolved}
 */
function getURLPar(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null)
        return unescape(r[2]);
    return null;
}

/**
 * 设置URL中参数值
 * @param {type} url
 * @param {type} ref
 * @param {type} value
 * @returns {String}
 */
function changeURLPar(url, ref, value) {
    var str = "";
    if (url.indexOf('?') != -1)
        str = url.substr(url.indexOf('?') + 1);
    else
        return url + "?" + ref + "=" + value;
    var returnurl = "";
    var setparam = "";
    var arr;
    var modify = "0";
    if (str.indexOf('&') != -1) {
        arr = str.split('&');
        for (i in arr) {
            if (arr[i].split('=')[0] == ref) {
                setparam = value;
                modify = "1";
            }
            else {
                setparam = arr[i].split('=')[1];
            }
            returnurl = returnurl + arr[i].split('=')[0] + "=" + setparam + "&";
        }
        returnurl = returnurl.substr(0, returnurl.length - 1);
        if (modify == "0")
            if (returnurl == str)
                returnurl = returnurl + "&" + ref + "=" + value;
    }
    else {
        if (str.indexOf('=') != -1) {
            arr = str.split('=');
            if (arr[0] == ref) {
                setparam = value;
                modify = "1";
            }
            else {
                setparam = arr[1];
            }
            returnurl = arr[0] + "=" + setparam;
            if (modify == "0")
                if (returnurl == str)
                    returnurl = returnurl + "&" + ref + "=" + value;
        }
        else
            returnurl = ref + "=" + value;
    }
    return url.substr(0, url.indexOf('?')) + "?" + returnurl;
}


function gitemscreen_delete(id){
    $.ajax({
        url: "./index.php?act=gameitem&st=gscreen_delete",
        dataType: "json",
        processData: false,
        data: 'id='+id,
        success: function(data){
            if(data == 1){
               alert('删除成功');
               $("#screen"+id).parent().remove();
               }
            },
            error: function(){
                alert('删除失败');
            }
     });
}

/**
 *优惠券添加小类
 *@return {undefined}
 */
function addChildClass()
{
    var key = $("#hide").val();
    var last = 1;
    $("#child_code").each(function(){
        var last = $(this).val();
        if(last > $("#hide").val())
        {
            $("#hide").val(last);
        }
    });

    key = parseInt(key) + parseInt(1);
    var key1 = key;
    if(key < 10)
    {
        key1 = '0'+key;
    }
    else if(key > 99)
    {
        alert('最多可添加99个！');
    }
    
    var txt = "<table align='left' class='child_table' style='margin-top:10px'><tr><td><div class='child_t' id='child_code'>"+key1+"</div></td><td class='child_r'><span class='del' title='点击删除' onClick='deleteChildClass()'><font color='blue' size='+1'><b>删除</b></font></h5></span></td></tr><tr><td><div class='child_t'>金额：</div></td><td><div class='child_t'><input type='text' name='account' id='account' value='' maxlength='6'></div></td></tr><tr><td><div class='child_t'>开始使用时间：</div></td><td><div class='child_t'><select name='time_type' id='time_type'><option value='1'>获得时间</option></select>&nbsp;<font size='+2'>+ </font>&nbsp;<input type='text' name='delay_day' id='delay_day' value='0'>天</div></td></tr><tr><td><div class='child_t'>有效期：</div></td><td><div class='child_t'><input type='text' id='effective_day' name='effective_day'>天</div></td></tr></table>";
    $("#child_class").append(txt);
    $("#hide").attr("value",key);
}

/**
 *删除小类
 *@return {undefined}
 */
function deleteChildClass()
{
    $('.child_table').bind('click', function() {
        $(this).remove();
        $('.child_table').unbind();
        var i=0;
        $(".child_table").each(function(){
            i++;
            if(i<10)
            {
                i = '0'+i;
            }
            $(this).find("#child_code").text(i);
            $("#hide").val(i);
        })
    });
}

/*
 * 添加优惠券
 * @return {json}
 * @param {array}
 * 2013/7/1
 */
function addCoupon()
{
    $("#refer").val("");
    var batch_code = $("#batch_code").text();
    var batch_cate = $("#type option:selected").val();
	var coupon_count = $("#coupon_count").val();
    var batch_name = $("#coupon_name").val();
    var child         = new Array();
    var account       = new Array();
    //var start_time    = new Array();
    var delay_day     = new Array();
    var effective_day = new Array();
    var pageUrl       = new Array();
    var pageRule      = new Array();
  

    //验证
	if(coupon_count == '')
	{
		alert('单个用户可领取次数，不能为空！');
		$("#coupon_count").focus();
		$("#refer").val("1");
		return false;
	}
	else
	{
		if(isNaN(coupon_count))
		{
			alert('领取次数必须是数值类型！');
			$("#coupon_count").focus();
			$("#coupon_count").val('');
			$("#refer").val("1");
			return false;
		}
		else
		{
			//领取次数不支持小数
			var mode = /\./;
			if(mode.test(coupon_count))
			{
				alert("对不起，领取次数不支持小数");
				$("#coupon_count").focus();
				$("#refer").val("1");
				return false;
			}
			
			if(coupon_count <= 0 || coupon_count > 4294967295)
			{
				alert('领取次数填写数值范围有问题！');
				$("#coupon_count").focus();
				$("#refer").val("1");
				return false;
			}
		}
	}
	
    if(batch_name == '')
    {
        alert('名称格式不正确，不能为空！');
		$("#coupon_name").focus();
        $("#refer").val("1");
        return false;
    }
	
    var length = batch_name.length;
    if(length > 50)
    {
        alert('名称格式不正确，最多可输入50个字符！');
        $("#refer").val("1");
        return false;
    }


    $(".child_table").each(function(){
        var code = $(this).find("#child_code").text();
        child.push(code);
        var acc = $(this).find("#account").val();
        //验证金额
        /*var exp = /^[1-9][0-9]{0,2}$/;
        if(!exp.test(acc))
        {
            alert("请输入一个不大于999正整数！编号："+code+",金额输入框");
            $("#refer").val("1");
            return false;
        }*/
		if(acc == '')
		{
			alert("请输入一个不大于999正整数！编号："+code+",金额输入框");
			$("#refer").val("1");
			return false;
		}
		else
		{
			if(isNaN(acc))
			{
				alert(acc + " 必须是数值类型！编号："+code+"金额输入框");
				$("#refer").val("1");
				return false;
			}
			else
			{
				if(acc <= 0)
				{
					alert("请输入一个不大于999正整数！编号："+code+",金额输入框");
					$("#refer").val("1");
					return false;
				}
				
				if(acc > 999)
				{
					alert("请输入一个不大于999正整数！编号："+code+",金额输入框");
					$("#refer").val("1");
					return false;
				}
				
				if(acc.length > 6)
				{
					alert("金额字符长度太长了！编号："+code+",金额输入框");
					$("#refer").val("1");
					return false;
				}
				
				//验证是否存在小数点，存在则需要验证小数点位数必须1-2位
				var mode = /\./;
				if(mode.test(acc))
				{
					//验证小数点只能有2位数
					var exp = /^\d+\.{1,1}\d{1,2}$/;
					if(!exp.test(acc))
					{
						alert("对不起，请检测你输入字符，是否为数字，小数点默认保留2位！编号："+code+",金额输入框");
						$("#refer").val("1");
						return false;
					}
				}
			}
		}
		
        account.push(acc);
        var delay = $(this).find("#delay_day").val();
        //验证延迟天数
        var exps = /^\d+$/;
        if(!exps.test(delay) || delay<0 || delay>360)
        {  
            alert("请输入一个正整数且最大为360！编号："+code+",延迟天数输入框");
            $("#refer").val("1");
            return false;
        }


        delay_day.push(delay);
        //start_time.push($(this).find("#time_type option:selected").val());
        //验证有效天数
        var expes = /^[1-9][0-9]{0,1}$/;
        var eff = $(this).find("#effective_day").val();
        if(!expes.test(eff))
        {
            alert("请输入一个正整数且最大为99！编号："+code+",有效天数输入框");
            $("#refer").val("1");
            return false;
        }
        effective_day.push(eff);     
    });
    
    //验证未通过
    if($("#refer").val() == "1")
    {
        return false;
    }
    else
    {
        $.ajax({
            type:"POST",
            url:"./index.php?act=coupon&st=addNewCoupon",
            data:"batchCode="+batch_code+"&batchCate="+batch_cate+"&coupon_count="+coupon_count+"&batchName="+batch_name+"&childCode="+child+"&account="+account+"&delayDay="+delay_day+"&effectiveDay="+effective_day,
            dataType:"json",
            success:function(msg){
                alert(msg.message);
                if(msg.status)
                {
                    window.location.href = './index.php?act=coupon&st=addCoupon';
                }
            }
        });
    }  
}

//优惠券搜索条件验证
function checkCondition()
{
    $("#hid").val("");
    var coupon_id = $("#coupon_id").val();
    var coupon_name = $("#coupon_name").val();
    var order_id = $("#order_sn").val();
    var start_time = $("#start_time").val();
    var end_time = $("#end_time").val();
    var amounts = $("#amounts").val();
    var user_name = $("#user_name").val();

    var exp = /^[A-Z][0-9]{0,22}$/;
    var len_id = coupon_id.length;
    if(len_id > 23)
    {
        alert("字符不超过23个！");
        $("#hid").val("1");
        return false;
    }

    if(!exp.test(coupon_id) && coupon_id)
    {
        alert("格式不正确，请重新输入！");
        $("#hid").val("1");
        return false;
    }

    var len_name = coupon_name.length;
    if(len_name > 100)
    {
        alert("名称不正确，不超过100字符");
        $("#hid").val("1");
        return false;
    }

    if(start_time == '' && end_time != '')
    {
        alert("请输入起始时间");
        $("#hid").val("1");
        return false;
    }
    if(end_time == '' && start_time != '')
    {
        alert("请输入结束时间");
        $("#hid").val("1");
        return false;
    }

    if(start_time > end_time)
    {
        alert("时间区间选择不正确！");
        $("#hid").val("1");
        return false;
    }

    var len_user = user_name.length;
    if(len_user > 50)
    {
        alert("名称格式不正确，字符不超过50个！");
        $("#hid").val("1");
        return false;
    }

    var len_order = order_id.length;
    if(len_order > 50)
    {
        alert("名称格式不正确，字符不超过50个！");
        $("#hid").val("1");
        return false;
    }

    var expe = /^[1-9][0-9]{0,2}$/;
    if(!expe.test(amounts) && amounts)
    {
        alert("格式不正确，最多只能输入3位数！");
        $("#hid").val("1");
        return false;
    }

    if($("#hid").val() == '1')
    {
        return false;
    }
    else
    {
        var status = $("#status option:selected").val();
        var url = "coupon_id="+coupon_id+"&amounts="+amounts+"&coupon_name="+escape(coupon_name)+"&start_time="+start_time+"&end_time="+end_time+"&order_sn="+order_id+"&status="+status+"&user_name="+escape(user_name);
        window.location.href="index.php?act=coupon&st=searchCoupon&"+url;
    }
}

//获取兑换码数量
function select_param(obj)
{
    if(obj==1)
    {
        $("#batch_id").html("<option value=''>选择批次</option>");  
        $("#category").html("<option value=''>选择小类</option>"); 
    }
    if(obj==2)
    {
        $("#category").html("<option value=''>选择小类</option>"); 
    }
    var type  = $("#type :selected").val();
    var batch = $("#batch_id :selected").val();
    var cate  = $("#category :selected").val();

    $.ajax({
        type:"POST",
        url:"./index.php?act=coupon&st=getExchangeNum",
        data:"type="+type+"&batch_id="+batch+"&category="+cate,
        dataType:"JSON",
        success:function(msg){
            if(msg.menus)
            {
                var content = "<option value=''>选择批次</option>";
                $.each(msg.menus, function(i, v)
                {
                    content += "<option value="+v+">"+v+"</option>";
                });
                $("#batch_id").html(content);                
            }
            if(msg.menut)
            {
                var content = "<option value=''>选择小类</option>";
                $.each(msg.menut, function(i, v)
                {
                    content += "<option value="+v+">"+v+"</option>";
                });
                $("#category").html(content);                
            }
            if(msg.res)
            {
                var content = "已有"+msg.res+"个兑换码";
                $("#count").html(content);                
            }
        }
    });
}

//添加兑换码
function addNewExchange() {
    var type    = $("#type :selected").val();
    var batch   = $("#batch_id :selected").val();
    var cate    = $("#category :selected").val();
    var remark  = $("#remark").val();
    var date    = $("#end_time").val();
    var file    = $("#exchange_code").val();
    var pas     = $("#pas").val();

    if(pas=="1")
    {
        alert("请重新上传文件！");
        return false;
    }
    if(type=="")
    {
        alert("请选择类别！");
        return false;
    }
    if(batch=="")
    {
        alert("请选择批次！");
        return false;
    }
    if(cate=="")
    {
        alert("请选择小类!");
        return false;
    }
    if(remark.length > 50)
    {
        alert("备注内容不大于50个字！");
        return false;
    }
    if(file == "")
    {
        alert("请选择上传文件！");
        return false;
    }
    if(date=="")
    {
        alert("过期时间不能为空！");
        return false;
    }
    

    $("#addNew").attr("disabled", "true");
    $("#note").html("<img src='../files/images/huodong/wait.gif'>新增优惠券兑换码，请稍后...");
    $.ajax({
        type:"POST",
        url:"./index.php?act=coupon&st=addNewExchangeCode",
        data:"type="+type+"&batch_id="+batch+"&category="+cate+"&remark="+escape(remark)+"&time="+date,
        dataType:"JSON",
        success:function(msg){
            var param;
            if(msg.status)
            {
                param = 0;
            }
            else
            {
                param = 1;
            }
            location.href = "./index.php?act=coupon&st=exchangeRes&num="+msg.num+"&batch_id="+batch+"&type="+type+"&category="+cate+"&display="+param;
        }
    });
}

//自动上传
function autoupload()
{
    $("#myupload").ajaxSubmit({
        dataType:"json",
        success: function(msg) {
                if(msg.status)
                {
                   $("#pas").val("");
                   $("#note_sum").html("共有"+msg.info+"条数据");
                }
                else
                {
                    $("#pas").val("1");
                    $("#note_sum").html('<font color=red>'+msg.message+'</font>');
                }
            }
    });
}

//添加模块
function check_form()
{
    var module_name = $("#module_name").val();
    var module_action = $("#module_action").val();
    var module_sort = $("#sort").val();

    if(module_name == '')
    {
        alert("模块名不为空！");
        return false;
    }
    if(module_action == '')
    {
        alert("脚本不为空！");
        return false;
    }
    if(module_sort == "")
    {
        alert("排序号不为空！");
        return false;
    }
    else
    {
        var patt = /^[1-9][0-9]*/;
        if(!patt.test(module_sort))
        {
            alert("格式不正确，请填写一个自然整数！");
            return false;
        }
    }

    $("#my_form").submit();
}

//添加操作
function check_action()
{
    var action_name = $("#action_name").val();
    var action_code = $("#action_code").val();
    var action_sort = $("#sort").val();

    if(action_name == '')
    {
        alert("模块名不为空！");
        return false;
    }
    if(action_code == '')
    {
        alert("脚本不为空！");
        return false;
    }
    if(action_sort == "")
    {
        alert("排序号不为空！");
        return false;
    }
    else
    {
        var patt = /^[1-9][0-9]*/;
        if(!patt.test(action_sort))
        {
            alert("格式不正确，请填写一个自然整数！");
            return false;
        }
    }

    $("#my_form").submit();
}

//选择期号先检测彩种
function checkCate()
{
    var lottery_type_id = $("select[name=lottery_type_id] option:selected").val();
    if(lottery_type_id == '')
    {
        alert('请先选择彩种！');
    }
}

//充值申请
//chargeApply.html

function account_charge()
{
    $("#account").css({color:"#000"});
    var account_charge = $("#account").val();
    if(account_charge == '请输入整数金额')
    {
        $("#account").val("");
        $("#submit").data("account_flag",0);
    }
}

function brief_charge()
{
    $("#brief").css({color:"#000"});
    var brief_charge = $("#brief").val();
    if(brief_charge == '请输入简要,最多20字')
    {
        $("#brief").val("");
        $("#submit").data("brief_flag",0);
    }
}

function remarks_charge()
{
    $("#remarks").css({color:"#000"});
    var remarks_charge = $("#remarks").val();
    if(remarks_charge == '请输入备注,最多200字')
    {
        $("#remarks").val("");
        $("#submit").data("remarks_flag",0);
    }
}

function account_blur() 
{
    var account = $("#account").val();
    $("#account_note").removeClass();
    if(account == '')
    {
        $("#account").val("请输入整数金额");
        $("#account").css({color:"#ddd"});
        $("#account_note").addClass("label label-warning");
        $("#account_note").text("请输入大于0小于5000000的整数");
        $("#submit").data("account_flag",0);
    }
    else
    {
        var exp = /^[1-9][0-9]{0,}$/;
        if(!exp.test(account))
        {
            //alert("格式不正确");
            $("#account_note").addClass("label label-warning");
            $("#account_note").text("格式不正确");
            $("#submit").data("account_flag",0);
        }
        else if(account < 0 || account > 5000000)
        {
            $("#account_note").addClass("label label-warning");
            $("#account_note").text("请输入大于0小于5000000的整数");
            $("#submit").data("account_flag",0);
        }
        else
        {
            $("#account_note").addClass("label label-success");
            $("#account_note").text("OK");
            $("#submit").data("account_flag",1);
        }
    }
}

function brief_blur()
{
    var brief = $("#brief").val();
    $("#brief_note").removeClass();
    if(brief == '')
    {
        $("#brief").val("请输入简要,最多20字");
        $("#brief").css({color:"#ddd"});
        $("#brief_note").addClass("label label-warning");
        $("#brief_note").text("请输入简要,最多20字");
        $("#submit").data("brief_flag",0);
    }
    else
    {
        var len = brief.length;
        if(len > 20)
        {
            //alert("已超过20个字");
            $("#brief_note").addClass("label label-warning");
            $("#brief_note").text("已超过20字");
            $("#submit").data("brief_flag",0);
        }
        else
        {
            $("#brief_note").addClass("label label-success");
            $("#brief_note").text("OK");
            $("#submit").data("brief_flag",1);
        }
    }
}

function remarks_blur()
{
    $("#remarks_note").removeClass();
    var remarks = $("#remarks").val();
    if(remarks == '')
    {
        $("#remarks").val("请输入备注,最多200字");
        $("#remarks").css({color:"#ddd"});
        $("#remarks_note").addClass("label label-warning");
        $("#remarks_note").text("请输入备注,最多200字");
        $("#submit").data("remarks_flag",0);
    }
    else
    {
        if(remarks.length > 200)
        {
            //alert("已超过200个字");
            $("#remarks_note").addClass("label label-warning");
            $("#remarks_note").text("已超过200个字");
            $("#submit").data("remarks_flag",0);
        }
        else
        {
            $("#remarks_note").addClass("label label-success");
            $("#remarks_note").text("OK");
            $("#submit").data("remarks_flag",1);
        }
    }
}

//提交充值申请
function charge_apply(obj){		
	//防止多次操作
	if ($('.btn_submit').hasClass('disabled')) return false;
    var user_flag = $("#submit").data("user_flag");
    var account_flag = $("#submit").data("account_flag");
    var brief_flag = $("#submit").data("brief_flag");
    var remarks_flag = $("#submit").data("remarks_flag");
    var account = $("#account").val();
    var brief = $("#brief").val();
    var remarks = $("#remarks").val();
    var activityid=$("#activityid").val();
	var remittance_pic=$("#remittance_pic").val();
    var recharge=$('input[name=recharge]:checked').val();
    var patt = /^(\+|-?)\d+$/;
	if(recharge == 2){
		if(account<=0){
			$("#account_note").addClass("label label-warning").text('充值金额不能为空').show();
			return false;
		}
		//银行转账
		if(bak.bank_account.status == 0 ){
			bak.bank_account.value = "";
			bak.bank_account.msg = bank_account_txt_default;
			bak.bank_account.status = 0;
            $("#bank_account_note").addClass("label label-warning").text(bank_account_txt_default).show();
			return false;
		}
		if(bak.phone.status == 0){
			bak.phone.value = "";
			bak.phone.msg = phone_txt_defualt;
			bak.phone.status = 0;
			$("#phone_note").addClass("label label-warning").text(phone_txt_defualt).show();
			return false;
		}
		var remittance_date = $('#remittance_date').datebox('getValue');
		if(remittance_date == ""){
			$("#remittance_date_note").addClass("label label-warning").text("转账日期不能为空").show();
			return false;
		}
		if(!/\d-/g.test(remittance_date)){
			$("#remittance_date_note").addClass("label label-warning").text("含有非法字符").show();
			return false;
		}
		if(remittance_pic==''){
			$("#remittance_pic_note").addClass("label label-warning").text("转账单据必须").show();
			return false;
		}
		$("#remittance_date_note").hide();
		var user_id= $("#user").attr("user_id");
		var action = "./index.php?act=finance&st=charge_apply_outline&user_id="+user_id+
				 "&account="+account+
			     "&brief="+brief+
			     "&remarks="+remarks+
			     "&activityid="+activityid+
			     "&recharge="+recharge+
			     "&bank_account="+bak.bank_account.value+
			     "&phone="+bak.phone.value+
				 "&remittance_date="+remittance_date;			
		//$("#frm_remittance_pic").attr("action",action).submit();		
		return true;
	}
	

    if(recharge==1 && activityid==''){
        alert('请输入活动id号');
        return false;
    }
    if(account_flag == 1 && brief_flag == 1 && remarks_flag == 1)
    {    
        var user_id= $("#user").val();
        if(recharge==1 && activityid!=''){
            if(!patt.test(activityid)){
                alert('活动id必须为整数');
                return false;
            }
            $.getJSON('./index.php?act=finance&st=checkactivity&activityid='+activityid,function(data){
                if(data.status==false){
                    alert('活动id号不存在');
                    return false;
                    }else{
                         $.ajax({
                         type:"POST",
                         url:"./index.php?act=finance&st=chargeApply",
                         data:"user_id="+user_id+"&account="+account+"&brief="+brief+"&remarks="+remarks+"&activityid="+activityid+"&recharge="+recharge,
                         dataType:"json",
                        beforeSend:function(){
                             $('.btn_submit').addClass('disabled').val('操作中');
                       },
                        success:function(msg){
                             alert(msg.message);
							 window.location.href="../index.php?act=finance&st=chargeApply";
                        }
                    });
                    }
                });
            }else{
        $.ajax({
            type:"POST",
            url:"./index.php?act=finance&st=chargeApply",
            data:"user_id="+user_id+"&account="+account+"&brief="+brief+"&remarks="+remarks+"&activityid="+activityid+"&recharge="+recharge,
            dataType:"json",
			beforeSend:function(){
				$('.btn_submit').addClass('disabled').val('操作中');
			},
            success:function(msg){
                alert(msg.message);
                window.location.href="../index.php?act=finance&st=chargeApply";
            }
        });
    }
}
    else{
        alert("不能提交,请检查输入错误");
    }
}
var bank_account_txt_default = "请输入银行卡账号";
var bank_account_txt_nonum = "字符格式有误";

var phone_txt_defualt = "请输入手机号码";
var phone_txt_nonum = "手机号码字符有误";
var phone_txt_novalid = "手机号码无效";

var bak = {};
	bak.bank_account = {value:"",msg:bank_account_txt_default,status:0};
	bak.phone		 = {value:"",msg:phone_txt_defualt,status:0};
$(function(){
	//以下校验只做为空字符校验有误的
	//银行账号

	var color = "#aaa";
	$("#bank_account").val(bank_account_txt_default).css({color:color}).focus(function(){
		var val = $.trim($(this).val());		
		if( val == bank_account_txt_default||val == bank_account_txt_nonum){
			$(this).val("");			
			$("#bank_account_note").text("").hide();
			return;
		}		
		$(this).css({color:"#000"});
	}).blur(function(){		
		var val = $.trim($(this).val());
		if(val == ""){
			bak.bank_account.value = "";
			bak.bank_account.msg = bank_account_txt_default;
			bak.bank_account.status = 0;
            $("#bank_account_note").addClass("label label-warning").text(bank_account_txt_default).show();
			return;
		}
		if(!/\d/g.test(val)){
			bak.bank_account.value = "";
			bak.bank_account.msg = bank_account_txt_nonum;
			bak.bank_account.status = 0;
            $("#bank_account_note").addClass("label label-warning").text(bank_account_txt_nonum).show();
			return;			
		}
		bak.bank_account.value = val;
		bak.bank_account.status = 1;
		bak.bank_account.msg = "";
		$(this).css({color:color});
		$("#bank_account_note").addClass("label label-success").text("OK").show();
	});
	//转账日期
	//手机号码
	$("#phone").focus(function(){
		var val = $.trim($(this).val());
		if(val == phone_txt_defualt||val == phone_txt_nonum){
			$(this).val('');
			$("#phone_note").text("").hide();
		}
		$(this).css({color:"#000"});
	}).blur(function(){
		var val = $.trim($(this).val());
		if(val == ""){
			bak.phone.value = "";
			bak.phone.msg = phone_txt_defualt;
			bak.phone.status = 0;
			$("#phone_note").addClass("label label-warning").text(phone_txt_defualt).show();
			return;
		}
		if(!/\d/g.test(val)){
			bak.phone.value = "";
			bak.phone.msg = phone_txt_nonum;
			bak.phone.status = 0;
            $("#phone_note").addClass("label label-warning").text(phone_txt_nonum).show();
			return;			
		}
		if(!/^1[3|4|5|8][0-9]\d{8}$/.test(val)){
			bak.phone.value = "";
			bak.phone.msg = phone_txt_novalid;
			bak.phone.status = 0;
            $("#phone_note").addClass("label label-warning").text(phone_txt_novalid).show();			
			return;
		}
		bak.phone.value = val;
		bak.phone.status = 1;
		bak.phone.msg = '';
		$(this).css({color:color});
		$("#phone_note").addClass("label label-success").text("OK").show();
	});
});